<?php
declare(strict_types=1);

namespace addons\WeChatMini\driver;

use WeChat\Contracts\BasicWeChat;

class Deliver extends BasicWeChat
{
    /**
     * 发货信息录入
     */
    public function deliverAdd($data)
    {
        $url = 'https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=ACCESS_TOKEN';

        return $this->callPostApi($url, $data, true);
    }

    /**
     * 发货查询
     */
    public function deliverQuery($data)
    {
        $url = 'https://api.weixin.qq.com/wxa/sec/order/get_order?access_token=ACCESS_TOKEN';

        return $this->callPostApi($url, $data, true);
    }

    /**
     * 确认收货提醒
     */
    public function confirmReceipt($data)
    {
        $url = 'https://api.weixin.qq.com/wxa/sec/order/notify_confirm_receive?access_token=ACCESS_TOKEN';

        return $this->callPostApi($url, $data, true);
    }

    /**
     * 查询小程序是否已开通发货信息管理服务
     */
    public function isTradeManaged($data)
    {
        $url = 'https://api.weixin.qq.com/wxa/sec/order/is_trade_managed?access_token=ACCESS_TOKEN';

        return $this->callPostApi($url, $data, true);
    }

    /**
     * 获取快递公司列表
     */
    public function getCompanyList()
    {
        $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/get_delivery_list?access_token=ACCESS_TOKEN';

        return $this->callPostApi($url, [], true);
    }

    /**
     * 商户使用此接口向微信提供某交易单号对应的运单号
     */
    public function traceWaybill($data)
    {
        $url = 'https://api.weixin.qq.com/cgi-bin/express/delivery/open_msg/trace_waybill?access_token=ACCESS_TOKEN';

        return $this->callPostApi($url, $data, true);
    }
}